home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
chckrs.exe
/
CHCKRS.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-05-13
|
9KB
|
385 lines
Program Damas;
uses
Crt;
var
Ch,Piez1,Piez2,PiezAct : Char;
Archivo,Turno,Jug1,Jug2,LinArr,LinAba,Lin1,Lin2 : String;
t : String[80];
Comidas1,Comidas2,Empieza,x,y,z,a,b,c,p,q,j,k : Integer;
Selec,Salir : Boolean;
f : text;
Fichas : array[1..8, 1..4] of Char;
Procedure Inicio;
begin
ClrScr;
Write('Jugador #1: ');
ReadLn(Jug1);
Write('Jugador #2: ');
ReadLn(Jug2);
WriteLn;
Write('"Quin juega primero? (1 c 2): ');
ReadLn(t);
Jug2 := Jug2 + #32;
Val(t,Empieza,x);
Piez1 := 'x';
Piez2 := 'o';
if ((Empieza <> 1) or (Empieza <> 2)) then Empieza := 1;
if Empieza = 2 then begin
Turno := Jug2;
PiezAct := Piez2; end
else if Empieza = 1 then begin
Turno := Jug1;
PiezAct := Piez1; end;
Comidas1 := 0;
Comidas2 := 0;
for x := 1 to 3 do
begin
for y := 1 to 4 do
begin
Fichas[x,y] := 'x';
Fichas[x+2,y] := '.';
Fichas[x+5,y] := 'o';
end;
end;
a := 4;
b := 2;
Selec := False;
Salir := False;
end;
Procedure Tablero;
begin
ClrScr;
LinArr := #201;
LinAba := #200;
Lin1 := #186;
Lin2 := #199;
for x := 1 to 7 do
begin
LinArr := LinArr + #205#205#205#205#209;
LinAba := LinAba + #205#205#205#205#207;
Lin1 := Lin1 + #32#32#32#32#179;
Lin2 := Lin2 + #196#196#196#196#197;
end;
LinArr := LinArr + #205#205#205#205#187;
LinAba := LinAba + #205#205#205#205#188;
Lin1 := Lin1 + #32#32#32#32#186;
Lin2 := Lin2 + #196#196#196#196#182;
WriteLn(LinArr);
for x := 1 to 7 do
begin
WriteLn(Lin1);
WriteLn(Lin2);
end;
WriteLn(Lin1);
WriteLn(LinAba);
GotoXY(45,2);
Write('Jugador #1: ',Jug1);
GotoXY(45,15);
Write('Jugador #2: ',Jug2);
GotoXY(48,3);
Write('Comidas: ');
GotoXY(48,16);
Write('Comidas: ');
GotoXY(50,9);
Write('TURNO');
GotoXY(5,20);
WriteLn('Use '#24,',',#25,',',#27,' y ',#26,' para mover el cursor.');
GotoXY(5,21);
WriteLn('ESPACIO para seleccionar pieza a mover. ');
GotoXY(5,22);
WriteLn('ESC para salir del juego. ');
for x := 1 to 4 do
begin
z := 0;
for y := 1 to 4 do
begin
GotoXY(4+z,4*x-2);
Write(Fichas[2*x-1,y]);
Inc(z,10);
end;
WriteLn;
end;
for x := 1 to 4 do
begin
z := 5;
for y := 1 to 4 do
begin
GotoXY(4+z,4*x);
Write(Fichas[2*x,y]);
Inc(z,10);
end;
WriteLn;
end;
end;
Procedure Status;
begin
GotoXY(57,3);
Write(Comidas1);
GotoXY(57,16);
Write(Comidas2);
GotoXY(52,8);
Write(#32);
GotoXY(52,10);
Write(#32);
if Turno = Jug1 then
begin
GotoXY(52,8);
Write(#24);
end;
if Turno = Jug2 then
begin
GotoXY(52,10);
Write(#25);
end;
end;
Procedure SelectOff;
begin
GotoXY(5,20);
WriteLn('Use '#24,',',#25,',',#27,' y ',#26,' para mover el cursor.');
GotoXY(5,21);
WriteLn('ENTER para mover la pieza a la posicicn deseada.');
GotoXY(5,22);
WriteLn('ESPACIO para des-seleccionar la pieza marcada.');
if b mod 2 = 0 then
begin
x := (b div 2);
y := (a div 10) + 1;
end
else
begin
x := (b div 2) - 1;
y := (a div 10) - 4;
end;
GotoXY(a,b);
TextColor(135);
Write(Fichas[x,y]);
NormVideo;
c := a;
z := b;
Selec := True;
end;
Procedure Comer;
begin
if Turno = Jug1 then
begin
Inc(Comidas1);
end
else
begin
Inc(Comidas2);
end;
end;
Procedure Invalido;
begin
GotoXY(10,18);
TextColor(135);
Write('Movimiento inv lido! Por favor intente de nuevo.');
repeat until KeyPressed;
GotoXY(10,18);
NormVideo;
for x := 1 to 70 do Write(#32);
Exit;
end;
Procedure SelectOn;
begin
Status;
GotoXY(5,20);
WriteLn('Use '#24,',',#25,',',#27,' y ',#26,' para mover el cursor.');
GotoXY(5,21);
WriteLn('ESPACIO para seleccionar pieza a mover. ');
GotoXY(5,22);
WriteLn('ESC para salir del juego. ');
if b mod 2 = 0 then
begin
p := (b div 2);
q := (a div 10) + 1;
end
else
begin
p := (b div 2) - 1;
q := (a div 10) - 4;
end;
if (p = x) and (q = y) then
begin
GotoXY(a,b);
TextColor(7);
Write(Fichas[x,y]);
NormVideo;
if Selec = True then Selec := False;
Exit;
end;
if (((p = x+1) or (p = x-1)) and ((q=y) or (q = y+1) or (q = y-1))) then
begin
if p = x+1 then
if PiezAct = Piez2 then
begin
Invalido;
GotoXY(c,z);
NormVideo;
Write(Fichas[x,y]);
Exit;
end;
if p = x-1 then
if PiezAct = Piez1 then
begin
Invalido;
GotoXY(c,z);
NormVideo;
Write(Fichas[x,y]);
Exit;
end;
GotoXY(c,z);
Write('.');
GotoXY(a,b);
Write(Fichas[x,y]);
Fichas[p,q] := Fichas[x,y];
Fichas[x,y] := '.';
if Turno = Jug1 then
begin
Turno := Jug2;
PiezAct := Piez2;
end
else
begin
Turno := Jug1;
PiezAct := Piez1;
end;
if Selec = True then Selec := False;
Exit;
end;
if (((p = x+2) or (p = x-2)) and ((q=y) or (q = y+1) or (q = y-1))) then
begin
GotoXY(c,z);
Write('.');
GotoXY(a,b);
Write(Fichas[x,y]);
Fichas[p,q] := Fichas[x,y];
Fichas[x,y] := '.';
if p = x+2 then
j := -2
else
j := 2;
if ((q=y+1) or ((q=y) and (c<a))) then
begin
GotoXY(a-5,b+j);
Write('.');
Fichas[x-1,y-1] := '.';
end;
if ((q=y-1) or ((q=y) and (c>a))) then
begin
GotoXY(a+5,b+j);
Write('.');
Fichas[x-1,y+1] := '.';
end;
Fichas[p,q] := Fichas[x,y];
Fichas[x,y] := '.';
Comer;
if Turno = Jug1 then Turno := Jug2
else Turno := Jug1;
if Selec = True then Selec := False;
Exit;
end;
GotoXY(c,z);
TextColor(7);
Write(Fichas[x,y]);
NormVideo;
Selec := False;
end;
Procedure Escape;
begin
ClrScr;
WriteLn('Juego Terminado ...');
WriteLn;
WriteLn('1. Guardar el juego actual en disco');
WriteLn('2. Salir sin guardar');
WriteLn;
Write('Opcicn: ');
ReadLn(t);
Val(t,x,y);
case x of
1:
begin
WriteLn;
Write('Ingrese el nombre del archivo (sin extensicn / 8 chars. m x): ');
ReadLn(Archivo);
a := 10-Length(Jug1);
b := 10-Length(Jug2);
for x := 0 to a do Jug1 := Jug1 + ' ';
for x := 0 to b do Jug2 := Jug2 + ' ';
Archivo := Copy(Archivo,1,8) + '.DAM';
Assign(f, Archivo);
Rewrite(f);
WriteLn(f, Jug1, Piez1);
WriteLn(f, Jug2, Piez2);
for x := 1 to 8 do
begin
for y := 1 to 4 do